#include <iostream>
#include <stdio.h>
using namespace std;
typedef long long LL;
const LL MOD=1e9+7;
LL POW(LL a, LL b) {
	LL tmp=a%MOD;
	LL res=1;
	while (b) {
		if (b&1) {
			res=(res*tmp)%MOD;
		}
		tmp=(tmp*tmp)%MOD;
		b=b>>1;
	}
	return res;
}
LL GCD(LL a, LL b) {
	return a%b==0? b : GCD(b, a%b);
}
int main() {
	LL T;
//	freopen("in1.txt","r", stdin);
	cin>>T;
	LL p,q,k;
	LL tmp;
	while (T--) {
		cin>>p>>q>>k;
		LL res=(1+POW(1-2*q*POW(p,MOD-2)%MOD,k))*POW(2,MOD-2)%MOD;
		if (res<0) res+=MOD;
		cout<<res<<endl;
	}
	return 0;
}
